#include<stdio.h>
int main()
{
	struct D_type
	{
		int y;
		int m;
		int d;
	};
	struct D_type D1;
	scanf("%d%d%d",&D1.y,&D1.m,&D1.d);
	if((D1.y%4==0&&D1.y%100!=0)||D1.y%400==0)
	{
		switch (D1.m)
		{
			case 1:break;
			case 2:D1.d+=31;break;
			case 3:D1.d+=60;break;
			case 4:D1.d+=91;break;
			case 5:D1.d+=121;break;
			case 6:D1.d+=152;break;
			case 7:D1.d+=182;break;
			case 8:D1.d+=213;break;
			case 9:D1.d+=244;break;
			case 10:D1.d+=274;break;
			case 11:D1.d+=305;break;
			case 12:D1.d+=335;break;
		}
		printf("%d\n",D1.d);
	}
	else
	{
		switch (D1.m)
		{
			case 1:break;
			case 2:D1.d+=31;break;
			case 3:D1.d+=59;break;
			case 4:D1.d+=90;break;
			case 5:D1.d+=120;break;
			case 6:D1.d+=151;break;
			case 7:D1.d+=181;break;
			case 8:D1.d+=212;break;
			case 9:D1.d+=243;break;
			case 10:D1.d+=273;break;
			case 11:D1.d+=304;break;
			case 12:D1.d+=334;break;
		}
		printf("%d\n",D1.d);
	}
}
